package com.itheima.service.impl;

import com.itheima.dao.UserDao;
import com.itheima.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

@Component("userService")
@Scope("singleton")
public class UserServiceImpl implements UserService {
    @Autowired
    @Qualifier("userDao")
    private UserDao userDao;

//    public void userDao(){
//        System.out.println("userDao method is running ...");
//    }


//    public UserServiceImpl(){
//        System.out.println("UserServiceImpl对象创建了...");
//    }
    @PostConstruct
    public void init(){
        System.out.println("init method is running...");
    }

    @Override
    public void save() {
        System.out.println("save method is running...");
        userDao.save();
    }

    @PreDestroy
    public void destroy(){
        System.out.println("destroy method is running...");
    }
}
